//
//  AnnounceView.m
//  time
//
//  Created by bingo on 2018/5/20.
//  Copyright © 2018年 1ge. All rights reserved.
//

#import "AnnounceView.h"
#import "SDCycleScrollView.h"
#import <Masonry/Masonry.h>

@interface AnnounceView ()<SDCycleScrollViewDelegate>
@property (nonatomic,weak) UIImageView *imageViewL;

@end
@implementation AnnounceView
- (instancetype)init {
    if (self = [super init]) {
        [self setUpUI];
        [self setLayout];
        self.backgroundColor = UIColorFromRGBHex(0x87CEFA);
    }
    return self;
}

-(void)setUpUI{
    self.backgroundColor = [UIColor redColor];
    UIImageView *imageViewL = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"announce"]];
    self.imageViewL = imageViewL;
    [self addSubview:imageViewL];
    
    SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil];
    cycleScrollView.scrollDirection = UICollectionViewScrollDirectionVertical;
    cycleScrollView.onlyDisplayText = YES;
    cycleScrollView.titleLabelBackgroundColor = [UIColor clearColor];
    cycleScrollView.titleLabelTextFont = [UIFont systemFontOfSize:15];
    cycleScrollView.titleLabelTextColor = [UIColor whiteColor];
    cycleScrollView.backgroundColor = [UIColor clearColor];
    cycleScrollView.autoScrollTimeInterval = 4;
    [cycleScrollView disableScrollGesture];
    self.cycleScrollView = cycleScrollView;
    [self addSubview:cycleScrollView];    
}

- (void)setTitlesArr:(NSArray *)titlesArr {
    _titlesArr = titlesArr;
    
    self.cycleScrollView.titlesGroup = _titlesArr;
}

-(void)setLayout{
    
    [self.imageViewL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset = 0;
        make.left.offset(12);
        make.width.height.mas_equalTo(22);
    }];
    
    
    [self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageViewL.mas_right).offset(-7);
        make.top.bottom.offset = 0;
        make.right.mas_equalTo(-15);
    }];
}

#pragma mark- Set

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
